#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
inline void read(int &x){
	int f=1;x=0;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar(); 
	x*=f;
}
int n,q,l[N],r[N];
inline void sol1(){
	while(q--){
		int op,x,y;
		read(op),read(x);
		if(op==1){
			read(l[x]),read(r[x]),--r[x];
			continue;
		}
		int a,b;
		read(a),read(y),read(b);
		long long ans=0;
		if(x<y){
			for(int i=x;i<y;++i,++a){
				if(l[i]<=a&&a<=r[i]) continue;
				if(a<l[i]) a=l[i];
				else ans+=a-r[i],a=r[i];
			}
		}else{
			for(int i=x;i>y;--i,++a){
				if(l[i]<=a&&a<=r[i]) continue;
				if(a<l[i]) a=l[i];
				else ans+=a-r[i],a=r[i];
			}
		}
		if(a>b) ans+=a-b;
		printf("%lld\n",ans);
	}
}
int main(){
	freopen("study.in","r",stdin);
	freopen("study.out","w",stdout);
	read(n),read(q);
	for(int i=1;i<n;++i) read(l[i]),read(r[i]),--r[i];
	sol1();
	return 0;
}

